//
//  UIBarbuttonItem+Extension.swift
//  weibo
//
//  Created by 李江波 on 16/10/7.
//  Copyright © 2016年 lijiangbo. All rights reserved.
//

import UIKit

extension UIBarButtonItem{

    
    
    /// 自定义UIBarButtonItem
    ///
    /// - parameter title:        标题
    /// - parameter target:       对象
    /// - parameter action:       事件
    /// - parameter isbackButton: 返回按钮
    ///
    /// - returns:UIBarButtonItem
    convenience init(title:String  ,target:Any ,action:Selector , isbackButton: Bool = false) {
        
        let btn = UIButton(title: title, normalColor: UIColor.gray, highlightedColor: UIColor.orange)
        
        if isbackButton {
            
            btn.setImage(UIImage(named: "navigationbar_back_withtext") , for: .normal)
            btn.setImage(UIImage(named: "navigationbar_back_withtext_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView: btn)
    }
}
